//
//  WonThePraiseController.m
//  OnionHome
//
//  Created by fengjie on 2019/9/14.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "WonThePraiseController.h"
#import "WonThePraiseCell.h"
#import "WonThePraiseModel.h"

@interface WonThePraiseController ()
/**listViewTool*/
@property (nonatomic,strong)UITableViewTool*listViewTool;
/**数据源*/
@property (nonatomic,strong)NSMutableArray*dataSoure;

@end

@implementation WonThePraiseController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"获得赞";
    [self createUI];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self setNavBarBackgroundAndNotClearColor];
}
-(void)createUI{
    [self.listViewTool.listView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
}
#pragma mark ---懒加载
-(UITableViewTool*)listViewTool{
    if(!_listViewTool){
        _listViewTool=[[UITableViewTool alloc] initWithFrame:CGRectZero style:UITableViewStylePlain registerCellClassName:NSStringFromClass([WonThePraiseCell class]) identifier:NSStringFromClass([WonThePraiseCell class]) dataArray:self.dataSoure delegate:self dataSourceBlock:^(id  _Nonnull TempCell, NSIndexPath * _Nonnull indexPath, id  _Nonnull TempData) {
            WonThePraiseCell * cell = (WonThePraiseCell *)TempCell;
            cell.model = (WonThePraiseModel *)TempData;
            
        } selectCell:^(id  _Nonnull TempCell, NSIndexPath * _Nonnull indexPath, id  _Nonnull TempData) {
            
        }];
        _listViewTool.listView.backgroundColor = RGB(236, 239, 243);
        [_listViewTool.listView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
//        [_listViewTool.listView setSeparatorColor:UIColorFromRGB(0xE7EEE7)];
    }
    return _listViewTool;
}
-(NSMutableArray *)dataSoure{
    if (!_dataSoure) {
        _dataSoure =[NSMutableArray array];
        _dataSoure =[NSMutableArray array];
        NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"WonThePraise" ofType:@"plist"];
           //当数据结构为数组时
        NSArray *array = [[NSArray alloc] initWithContentsOfFile:plistPath];
        [array enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            WonThePraiseModel *model = [WonThePraiseModel new];
            [model setValuesForKeysWithDictionary:obj];
            [_dataSoure addObject:model];
        }];
    }
    return _dataSoure;
}

@end
